<?php
namespace jy_xiyi;
defined('BY_JYA') or exit('error');
/*
	消息提醒
*/
class notice extends \plugin{
	public function notice_pei2buyer($order,$url=''){
		//清洗完成，配送上门
		$template_id=cfc('account')->get_tpl_template_id('OPENTM405637366','订单配送提醒');
		$wxapp_id=$order['wxapp_id'];
		if(!$_SESSION['wxapp_id'] && !$wxapp_id){
			$wxapp_id=cfc('fans')->get_appid($order['mid'],1);
		}
		if($_SESSION['wxapp_id'] || $wxapp_id){
			$wxapptemplate_id=cfc('wxapp_api',$wxapp_id)->get_tpl_template_id('31339',[2,3],'pei2buyer','订单配送提醒','jy_weishop');
		}	
		$message=array(
			'first'=>array('value'=>'您好!您的物品已清洗完成，正在配送中上门,请您保持手机的通畅。',"color" => "#4a5077"),
			'keyword1'=>array('value'=>$order['ordersn'],"color" => "#4a5077"),
			'keyword2'=>array('value'=>date('Y-m-d',time()),"color" => "#4a5077"),
			'keyword3'=>array('value'=>$order['goods'][0]['title'],"color" => "#4a5077"),
			'remark'=>array('value'=>'请耐心等候！如有疑问请联系在线客服！',"color" => "#4a5077"),
		);
		$wxappmsg=array(
			array('value'=>date('Y-m-d H:i:s',time())),
			array('value'=>$order['goods'][0]['title']),
		);
		if(!$url){
			$url='jy_xiyi/order.detail//id='.$order['id'];
		}
		$url=custom_url($url,true);
		cfc('account')->sendtwoNotice($order['mid'],$template_id,$message,$url,'pei2buyer','jy_weishop',$order['id']);
		if($_SESSION['wxapp_id'] && $wxapptemplate_id){
			$url='/jy_xiyi/order/detail/index?id='.$order['id'];
			$template_id=cfc('wxapp_api',$wxapp_id)->checktplNotice($order['mid'],$wxapptemplate_id,$wxappmsg,$url,'pei2buyer','jy_weishop',$order['id']);
		}
	}
	public function notice_create2seller($order,$first=''){
		//发送订单生成通知给卖方
		$template_id=cfc('account')->get_tpl_template_id('OPENTM205213550','订单生成通知');
		$message=array(
			'first'=>array('value'=>$first,"color" => "#4a5077"),
			'keyword1'=>array('value'=>date('Y-m-d H:i:s',$order['createtime']),"color" => "#4a5077"),
			'keyword2'=>array('value'=>$order['goods']['0']['title'].'等商品',"color" => "#4a5077"),
			'keyword3'=>array('value'=>$order['ordersn'],"color" => "#4a5077"),
			'remark'=>array('value'=>'请及时处理！',"color" => "#4a5077"),
		);
		if(method_exists(cfc('account'),'sendtwoNotice')){
			cfc('account')->sendtwoNotice($seller_id,$template_id,$message,'','create2seller','jy_weishop',$order['id']);
		}
	}
}
